﻿using Island;

public class Account
{
    public string id;
    public int sex;

    /// <summary>
    /// PBAccount转为Account
    /// </summary>
    public static Account FromPB(PBAccount pb)
    {
        Account acc = new Account();
        acc.id = pb.id;
        acc.sex = pb.sex;

        return acc;
    }

    /// <summary>
    /// Account转为PBAccount
    /// </summary>
    public PBAccount ToPB()
    {
        PBAccount pb = new PBAccount();
        pb.id = this.id;
        pb.sex = this.sex;

        return pb;
    }
}

[System.Serializable]
public class Location
{
    public float latitude; // 经度N 
    public float longitude; // 纬度E 

    public Location()
    {

    }
    public Location(float latitude, float longitude)
    {
        this.latitude = latitude;
        this.longitude = longitude;
    }

    /// <summary>
    /// Location转PBLocation
    /// </summary>
    public static Location FromPB(PBLocation pb)
    {
        Location loc = new Location();
        loc.latitude = pb.latitude;
        loc.longitude = pb.longitude;
        return loc;
    }

    /// <summary>
    /// 从PBLocation解析经纬度
    /// </summary>
    /// <param name="pb"></param>
    public void ParsePB(PBLocation pb)
    {
        this.latitude = pb.latitude;
        this.longitude = pb.longitude;
    }

    /// <summary>
    /// PBLocation转Location
    /// </summary>
    public PBLocation ToPB()
    {
        PBLocation pb = new PBLocation();
        pb.latitude = this.latitude;
        pb.longitude = this.longitude;
        return pb;
    }

    public static Location operator -(Location a, Location b)
    {
        Location c = new Location();
        c.latitude = a.latitude - b.latitude;
        c.longitude = a.longitude - b.longitude;
        return c;
    }
}
